package simple;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 05.04.12
 * Time: 16:19
 */

@Path(value = "test")
public class Endpoint {
    @GET
    public Response getResponse() throws Exception {
        SimpleEntity se = new SimpleEntity();

        EntityManagerFactory emf = Persistence.createEntityManagerFactory("example");
        EntityManager em = emf.createEntityManager();
        em.getTransaction().begin();
        em.persist(se);
        em.getTransaction().commit();

        return Response.ok(se).build();
    }
}
